{% extends 'front/front_base.html' %}
{% from 'common/_macro.html' import static %}
{% block head %}
    <link rel="stylesheet" href="{{ static('front/css/front_index.css') }}">
{% endblock %}
{% block title %}
勤才BBS首页
{% endblock %}
{% block body %}
<div class="lg-container">
    <div id="carousel-example-generic" class="carousel slide index-banner" data-ride="carousel">
    <!-- 指示器 -->
    <ol class="carousel-indicators">
        <li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
        <li data-target="#carousel-example-generic" data-slide-to="1"></li>
        <li data-target="#carousel-example-generic" data-slide-to="2"></li>
        <li data-target="#carousel-example-generic" data-slide-to="3"></li>
    </ol>
    <!-- 轮播图 -->
    <div class="carousel-inner"  role="listbox">
        {% for banner in banners %}
                {% if loop.first %}
                <div class="item active">
        {% else %}
                <div class="item">
        {% endif %}
            <a href="{{ banner.link_url }}" target="_blank">
                <img src="{{ banner.image_url }}" alt="">
            </a>
        </div>
        {% endfor %}
    </div>
    <!-- 控制按钮 -->
    <a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
        <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
        <span class="sr-only">Previous</span>
    </a>
    <a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
        <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
        <span class="sr-only">Next</span>
    </a>
</div>
    <div class="post-group">
        <ul class="post-group-head">
            {% if current_sort == 1 %}
                <li class="active" ><a href="{{ url_for('front.index',st=1,bd=current_board) }}">最新</a></li>
                {% else %}
                <li><a href="{{ url_for('front.index',st=1,bd=current_board) }}">最新</a></li>
            {% endif %}
            {% if current_sort == 2 %}
                <li class="active"><a href="{{ url_for('front.index',st=2,bd=current_board) }}">精华帖子</a></li>
                {% else %}
                <li><a href="{{ url_for('front.index',st=2,bd=current_board) }}">精华帖子</a></li>
            {% endif %}
            {% if current_sort == 3 %}
            <li class="active"><a href="{{ url_for('front.index',st=3,bd=current_board) }}">点赞最多</a></li>
                {% else %}
                <li><a href="{{ url_for('front.index',st=3,bd=current_board) }}">点赞最多</a></li>
            {% endif %}
            {% if current_sort  == 4%}
                <li class="active"><a href="{{ url_for('front.index',st=4,bd=current_board) }}">评论最多</a></li>
                {% else %}
                <li><a href="{{ url_for('front.index',st=4,bd=current_board) }}">评论最多</a></li>
            {% endif %}

        </ul>
        <ul class="post-list-group">
            {% for post in posts %}
                <li>
                    <div class="author-avatar-group">
                        <img src="{{ post.author.avatar or url_for('static',filename='imgs/front/logo3.png')}}" alt="">
                    </div>
                    <div class="post-info-group">
                        <a href="{{ url_for('front.pdetail',post_id = post.id) }}" class="post-title">{{ post.title }}</a>
                        {% if post.highlight %}
                            <span class="label label-danger">置顶</span>
                            <img src="http://bbs.fishc.com/static/image/common/digest_3.gif" align="absmiddle" alt="digest" title="精华 3">
                        {% endif %}
                        {% if post.firelag %}
                            <img src="http://bbs.fishc.com/static/image/common/hot_3.gif" align="absmiddle" alt="heatlevel" title="热度: 1258">
                            <img src="http://bbs.fishc.com/static/image/common/agree.gif" align="absmiddle" alt="agree" title="帖子被加分">
                        {% endif %}
                        <p class="post-info">
                            <span><a href="{{ url_for('front.profile',user_id = post.author.id) }}">{{ post.author.username }}</a></span>
                            <span>发布于{{ post.create_time | handle_time }}</span>
                            <span>评论:{{ post.comments | length }}</span>
                            <span>阅读:{{ post.read_count | int }}</span>
                        </p>
                    </div>
                </li>
            {% endfor %}
            <div class="page-nate">
                {{ pagination.links }}
            </div>
        </ul>
    </div>
</div>
<div class="sm-container">
    <div style="padding-bottom: 10px">
        <a href="{{ url_for('front.apost') }}" class="btn btn-warning btn-block ">发布帖子</a>
    </div>
    <div class="list-group">
    {% if current_board %}
        <a href="/" class="list-group-item" style="text-align: center">所有板块</a>
        {% else %}
        <a href="/" class="list-group-item active" style="text-align: center">所有板块</a>
    {% endif %}
        {% for board in boards %}
            {% if current_board == board.id %}
                <a href="{{ url_for('front.index',bd = board.id) }}" class="list-group-item active">{{ board.name }}<span class="badge">{{ board.posts | length }}</span></a>
                {% else %}
                <a href="{{ url_for('front.index',bd = board.id) }}" class="list-group-item">{{ board.name }}<span class="badge">{{ board.posts | length }}</span></a>
            {% endif %}
        {% endfor %}
    </div>
</div>
{% endblock %}